import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class TaskA extends Thread {
    public TaskA() {
        try {
            this.input = new BufferedReader(new FileReader("input.txt"));
            this.output = new PrintWriter("output.txt");
//            this.input = new BufferedReader(new InputStreamReader(System.in));
//            this.output = new PrintWriter(System.out);
            this.setPriority(Thread.MAX_PRIORITY);
        } catch (Exception e) {
            System.exit(666);
        }
    }

    static class Item {
        BigInteger min, max;

        public Item() {
            this.min = BigInteger.ONE;
            this.max = BigInteger.valueOf(100);
        }

        public Item(BigInteger min, BigInteger max) {
            this.min = min;
            this.max = max;
        }

        public Item(BigInteger exact) {
            this.min = exact;
            this.max = exact;
        }

        public Item add(Item another) {
            return new Item(this.min.add(another.min), this.max.add(another.max));
        }

        public Item multiply(Item another) {
            ArrayList<BigInteger> results = new ArrayList<BigInteger>();
            results.add(this.min.multiply(another.min));
            results.add(this.min.multiply(another.max));
            results.add(this.max.multiply(another.min));
            results.add(this.max.multiply(another.max));
            return new Item(Collections.min(results), Collections.max(results));
        }

        public Item subtract(Item another) {
            return new Item(this.min.subtract(another.max), this.max.subtract(another.min));
        }

        public Item max(Item another) {
            return new Item(this.min.max(another.min), this.max.max(another.max));
        }

        public Item min(Item another) {
            return new Item(this.min.min(another.min), this.max.min(another.max));
        }

        public Item divide() {
            BigInteger left, right;
            if (min.compareTo(BigInteger.ZERO) < 0) {
                left = min.subtract(BigInteger.ONE);
            } else {
                left = min;
            }
            if (max.compareTo(BigInteger.ZERO) < 0) {
                right = max.subtract(BigInteger.ONE);
            } else {
                right = max;
            }
            return new Item(left.divide(BigInteger.valueOf(2)), right.divide(BigInteger.valueOf(2)));
        }
    }


    static interface Expression {
        public Item calculate();
    }

    static class Number implements Expression {
        BigInteger value;

        public Number(BigInteger value) {
            this.value = value;
        }

        public Item calculate() {
            return new Item(value);
        }
    }

    static class Unknown implements Expression {
        public Unknown() {
        }

        public Item calculate() {
            return new Item();
        }
    }

    static class BinaryAction implements Expression {
        Expression left, right;
        char type;

        public BinaryAction(Expression left, Expression right, char type) {
            this.left = left;
            this.right = right;
            this.type = type;
        }

        public Item calculate() {
            Item l = left.calculate();
            Item r = right.calculate();
            switch (type) {
                case '+':
                    return l.add(r);
                case '-':
                    return l.subtract(r);
                case '*':
                    return l.multiply(r);
                case 'm':
                    return l.min(r);
                case 'M':
                    return l.max(r);
                default:
                    throw new IllegalArgumentException();
            }
        }
    }

    static class Divide implements Expression {
        Expression what;

        public Divide(Expression what) {
            this.what = what;
        }

        public Item calculate() {
            Item result = what.calculate();
            return result.divide();
        }
    }

    static Expression parseNumber() {
        String current = new String();
        while (WHERE < expression.length && Character.isDigit(expression[WHERE])) {
            current += expression[WHERE++];
        }
        return new Number(new BigInteger(current));
    }

    static Expression parseBrackets() {
        ++WHERE;
        Expression result = parse();
        ++WHERE;
        return result;
    }

    static Expression parseFunction() {
        char name = expression[WHERE];
        WHERE += 2;
        Expression left = parse();
        Expression result;
        if (name != 'D') {
            ++WHERE;
            Expression right = parse();
            result = new BinaryAction(left, right, name);
        } else {
            result = new Divide(left);
        }
        ++WHERE;
        return result;
    }

    static Expression parseNotOperation() {
        if (Character.isDigit(expression[WHERE])) {
            return parseNumber();
        } else if (expression[WHERE] == '(') {
            return parseBrackets();
        } else if (Character.isLetter(expression[WHERE])) {
            return parseFunction();
        } else if (expression[WHERE] == '?') {
            ++WHERE;
            return new Unknown();
        } else {
            return null;
        }
    }

    static Expression parse() {
        Expression tmp = parseNotOperation();
        Stack<Character> operations = new Stack<Character>();
        Stack<Expression> arguments = new Stack<Expression>();
        arguments.add(tmp);
        while (WHERE != expression.length) {
            if (expression[WHERE] == '+' || expression[WHERE] == '-') {
                while (!operations.empty()) {
                    char type = operations.pop();
                    Expression right = arguments.pop(), left = arguments.pop();
                    arguments.push(new BinaryAction(left, right, type));
                }
                operations.push(expression[WHERE]);
                ++WHERE;
                arguments.push(parseNotOperation());
            } else if (expression[WHERE] == '*') {
                operations.push(expression[WHERE]);
                ++WHERE;
                arguments.push(parseNotOperation());
            } else if (expression[WHERE] == ')' || expression[WHERE] == ',') {
                break;
            }
        }
        while (!operations.empty()) {
            char type = operations.pop();
            Expression right = arguments.pop(), left = arguments.pop();
            arguments.push(new BinaryAction(left, right, type));
        }
        return arguments.pop();
    }

    private void solve() throws Throwable {
        expression = nextToken().replace("div2", "D").replace("min", "m").replace("max", "M").toCharArray();
        Item result = parse().calculate();
        if (result.min.equals(result.max)) {
            output.println(result.min);
        } else {
            output.println("?");
        }
    }


    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

    public static void main(String[] args) {
        new TaskA().start();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private String nextToken() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    private static int WHERE = 0;
    private static char[] expression;
    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}